# Copyright (c) 2016 Ruslan Baratov
# All rights reserved.

cmake_minimum_required(VERSION 3.0)
project(Hunter)

include("@HUNTER_SELF@/cmake/Hunter")

include(hunter_autotools_project)
include(hunter_fatal_error)
include(hunter_status_debug)
include(hunter_assert_not_empty_string)

hunter_status_debug("Scheme: xcb")

if("@MSVC@")
  hunter_fatal_error("Autotools scheme not supported with Visual Studio")
endif()

set(
    DEPENDS_ON_PACKAGES
    xcb-proto
    pthread-stubs
    xau
)

foreach(x ${DEPENDS_ON_PACKAGES})
  hunter_add_package("${x}")
endforeach()

# Check preconditions
hunter_assert_not_empty_string("@HUNTER_SELF@")
hunter_assert_not_empty_string("@HUNTER_EP_NAME@")
hunter_assert_not_empty_string("@HUNTER_PACKAGE_URL@")
hunter_assert_not_empty_string("@HUNTER_PACKAGE_SHA1@")
hunter_assert_not_empty_string("@HUNTER_PACKAGE_DOWNLOAD_DIR@")
hunter_assert_not_empty_string("@HUNTER_PACKAGE_SOURCE_DIR@")
hunter_assert_not_empty_string("@HUNTER_PACKAGE_BUILD_DIR@")
hunter_assert_not_empty_string("@HUNTER_PACKAGE_INSTALL_PREFIX@")
hunter_assert_not_empty_string("@HUNTER_INSTALL_PREFIX@")
hunter_assert_not_empty_string("@HUNTER_GLOBAL_SCRIPT_DIR@")

hunter_autotools_project(
    "@HUNTER_EP_NAME@"
    HUNTER_SELF
      "@HUNTER_SELF@"
    URL
      @HUNTER_PACKAGE_URL@
    URL_HASH
      SHA1=@HUNTER_PACKAGE_SHA1@
    DOWNLOAD_DIR
      "@HUNTER_PACKAGE_DOWNLOAD_DIR@"
    SOURCE_DIR
      "@HUNTER_PACKAGE_SOURCE_DIR@"
    BUILD_DIR
      "@HUNTER_PACKAGE_BUILD_DIR@"
    INSTALL_DIR
      "@HUNTER_PACKAGE_INSTALL_PREFIX@"
    GLOBAL_INSTALL_DIR
      "@HUNTER_INSTALL_PREFIX@"
    PARALLEL_JOBS
      "@HUNTER_JOBS_OPTION@"
    PACKAGE_CONFIGURATION_TYPES
      "@HUNTER_PACKAGE_CONFIGURATION_TYPES@"
    EXTRA_FLAGS
       --without-doxygen
       --disable-devel-docs
)

set(PKG_CONFIG_MODULE xcb)

set(PKG_GENERATE_SHARED "${BUILD_SHARED_LIBS}")

# Use:
# * PKG_CONFIG_MODULE
# * DEPENDS_ON_PACKAGES
# * PKG_GENERATE_SHARED
configure_file(
    "@HUNTER_GLOBAL_SCRIPT_DIR@/pkgconfig-export-targets.cmake.in"
    "@HUNTER_PACKAGE_INSTALL_PREFIX@/lib/cmake/${PKG_CONFIG_MODULE}/${PKG_CONFIG_MODULE}Config.cmake"
    @ONLY
)
